<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/resources/css/font.css">
    <link rel="stylesheet" href="/resources/css/xadmin.css">
    <script type="text/javascript" src="/resources/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/resources/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <!-- @formatter:off -->
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="name" class="layui-form-label"><span class="x-red">*</span>客户名称</label>
                <div class="layui-input-inline"><input type="text" id="name" name="name" required autocomplete="on" class="layui-input"></div>
                <label for="fullName" class="layui-form-label"><span class="x-red">*</span>客户全称</label>
                <div class="layui-input-inline"><input type="text" id="fullName" name="fullName" required autocomplete="on" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="address" class="layui-form-label"><span class="x-red">*</span>地址</label>
                <div class="layui-input-inline"><input type="text" id="address" name="address" required lay-verify="number" autocomplete="on" class="layui-input"></div>
                <label for="fax" class="layui-form-label"><span class="x-red">*</span>传真</label>
                <div class="layui-input-inline"><input type="text" id="fax" name="fax" required lay-verify="number" autocomplete="on" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="mail" class="layui-form-label"><span class="x-red">*</span>邮箱</label>
                <div class="layui-input-inline"><input type="text" id="mail" name="mail" required lay-verify="email" autocomplete="on" class="layui-input"></div>
                <label for="manager" class="layui-form-label"><span class="x-red">*</span>经理姓名</label>
                <div class="layui-input-inline"><input type="text" id="manager" name="manager" required autocomplete="on" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label"><span class="x-red">*</span>联系电话</label>
                <div class="layui-input-inline"><input type="text" id="phone" name="phone" required autocomplete="on" class="layui-input"></div>
                <label for="status" class="layui-form-label"><span class="x-red">*</span>客户状态</label>
                <div class="layui-input-inline">
                    <select id="status" name="status" class="valid">
                        <option value="">客户状态</option>
                        <option value="未开始">有效</option>
                        <option value="无效">无效</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label for="introduce" class="layui-form-label">客户介绍</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="introduce" name="introduce" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="edit" lay-submit>添加</button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(function () {
        $ = layui.jquery;
        let form = layui.form;
        let layer = layui.layer;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(add)',
            function (data) {
                //发异步，把数据提交给后端
                let url = "/plan/orderAdd"
                $.ajax({
                    url: url,
                    type: 'post',
                    data: JSON.stringify(data.field),
                    processData: false,
                    contentType: "application/json",
                    success: function (res) {
                        console.log(res);
                        if (res.code == 200) {
                            layer.alert("增加成功", {icon: 6},
                                function () {
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                });
                        } else {
                            layer.alert(res.msg, {icon: 6})
                        }
                    },
                    error: function () {
                        layer.alert("网络错误", {icon: 6})
                    }
                })
                return false;
            });
    });
</script>

</html>